﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using blackhouse.BlackApart.Business.Furnitures;
using blackhouse.BlackApart.Business.Apartments;

namespace blackhouse.BlackApart.Web {
    public static class ImageUtils {

        #region Methods

        public static void FurnitureImage(Image image, IFurniture furniture) {
            SetImage(image, UrlUtils.FurnitureImageUrl(furniture.ImageName), furniture.Name);
        }

		public static void ApartmentPhotoGalleryImage(HyperLink imageLink, IApartmentPhoto photo, IApartmentGroup apartmentType) {
			string imageTitle = photo.Category;
			if (!string.IsNullOrEmpty(photo.Description))
				imageTitle += ", " + photo.Description;
			if (apartmentType != null)
				imageTitle = apartmentType.Name + " - " + imageTitle;

			imageLink.ImageUrl = UrlUtils.ApartmentPhotoSmallImageUrl(photo.PhotoName);
			imageLink.ToolTip = imageTitle;
			imageLink.NavigateUrl = UrlUtils.ApartmentPhotoBigImageUrl(photo.PhotoName);
			imageLink.Attributes.Add("prototypeurl", UrlUtils.ApartmentPhotoPrototypeImageUrl(photo.PhotoName));
			imageLink.Attributes.Add("gallerycategory", photo.Category);
			imageLink.Attributes.Add("gallerydescription", photo.Description);
		}

        public static void ApartmentPhotoSmallImage(Image photoImage, IApartmentPhoto photo) {
            string imageTitle = photo.Category;
            if (!string.IsNullOrEmpty(photo.Description))
                imageTitle += ", " + photo.Description;
            SetImage(photoImage, UrlUtils.ApartmentPhotoSmallImageUrl(photo.PhotoName), imageTitle);
            photoImage.Attributes.Add("category", photo.Category);
            photoImage.Attributes.Add("description", photo.Description);
        }

        public static void ApartmentPhotoReservationImage(Image photoImage, IApartmentPhoto photo) {
            string imageTitle = photo.Category;
            if (!string.IsNullOrEmpty(photo.Description))
                imageTitle += ", " + photo.Description;
            SetImage(photoImage, UrlUtils.ApartmentPhotoReservationImageUrl(photo.PhotoName), imageTitle);
        }

        public static void SetImage(Image image, string imageUrl, string imageDescription) {
            image.ImageUrl = imageUrl;
            image.ToolTip = imageDescription;
        }

        #endregion

    }
}